/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.model.master;

import com.kmcsoft.emaster.entity.TrackableEntity;
import com.kmcsoft.goldshop.model.scm.ImportJewelryDetail;
import java.util.ArrayList;
import java.util.List;
import javax.jdo.annotations.Column;
import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.FetchGroups;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 *
 * @author kmcsoft02
 */
@PersistenceCapable(detachable = "true", table = "SHOP_Product")
@FetchGroups(value = {
    @FetchGroup(name = "detach_Product_All", members = {
        @Persistent(name = "unit"),
        @Persistent(name = "importJewelryDetail"),
        @Persistent(name = "currency"),
        @Persistent(name = "costCurrency"),
        @Persistent(name = "statusHistoryProducts")
    }),
    @FetchGroup(name = "detach_Product_ProductStatusHistory", members = {
        @Persistent(name = "statusHistoryProducts")}),
    @FetchGroup(name = "detach_Product_ImportJewelryDetail", members = {
        @Persistent(name = "importJewelryDetail")}),
    @FetchGroup(name = "detach_Product_JewelryStyle", members = {
        @Persistent(name = "style")}),
    @FetchGroup(name = "detach_Product_Currency", members = {
        @Persistent(name = "currency")}),
    @FetchGroup(name = "detach_Product_Unit", members = {
        @Persistent(name = "unit")})})
public class Product extends TrackableEntity {

    public static final String STATUS_INSTOCK = "Cửa hàng";
    public static final String STATUS_SOLD = "Đã bán";
    public static final int TYPE_JEWELRY = 1;
    public static final int TYPE_PREMIUMJEWELRY = 2;
    public static final int TYPE_DIAMOND = 3;
    public static final int TYPE_GOLD = 4;
    @Persistent
    private String code;
    @Persistent
    private JewelryStyle style;
    @Persistent
    private String barcode;
    @Persistent
    private String name;
    @Persistent
    private String picture;
    @Persistent
    private String note;
    @Persistent
    private String status;
    @Persistent
    private Unit unit;
    @Persistent
    @Column(defaultValue = "0")
    private double cost;
    @Persistent
    private Currency costCurrency;
    @Persistent
    @Column(defaultValue = "0")
    private double costCurrencyExchange;
    @Persistent
    private Currency currency;//dong tien qui doi
    @Persistent
    @Column(defaultValue = "0")
    private int productType;
    @Persistent
    private List<ProductStatusHistory> statusHistoryProducts;
    @Persistent(mappedBy = "product")
    private ImportJewelryDetail importJewelryDetail;
    @Persistent
    private PricingPerson person;

    public Product() {
        statusHistoryProducts = new ArrayList<ProductStatusHistory>();
    }

    public int getProductType() {
        return productType;
    }

    public void setProductType(int productType) {
        this.productType = productType;
    }

    public ImportJewelryDetail getImportJewelryDetail() {
        return importJewelryDetail;
    }

    public void setImportJewelryDetail(ImportJewelryDetail importJewelryDetail) {
        this.importJewelryDetail = importJewelryDetail;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public List<ProductStatusHistory> getStatusHistoryProducts() {
        return statusHistoryProducts;
    }

    public void setStatusHistoryProducts(List<ProductStatusHistory> statusHistoryProducts) {
        this.statusHistoryProducts = statusHistoryProducts;
    }

    public JewelryStyle getStyle() {
        return style;
    }

    public void setStyle(JewelryStyle style) {
        this.style = style;
    }

    public Unit getUnit() {
        return unit;
    }

    public void setUnit(Unit unit) {
        this.unit = unit;
    }

    public Currency getCurrency() {
        return currency;
    }

    public void setCurrency(Currency currency) {
        this.currency = currency;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public Currency getCostCurrency() {
        return costCurrency;
    }

    public void setCostCurrency(Currency costCurrency) {
        this.costCurrency = costCurrency;
    }

    public double getCostCurrencyExchange() {
        return costCurrencyExchange;
    }

    public void setCostCurrencyExchange(double costCurrencyExchange) {
        this.costCurrencyExchange = costCurrencyExchange;
    }

    public double getCostInBasicCurrency() {
        return cost * costCurrencyExchange;
    }

    public PricingPerson getPerson() {
        return person;
    }

    public void setPerson(PricingPerson person) {
        this.person = person;
    }
}
